package com.mj.haier.rrskx.web.rest;

import java.util.List;

import com.mj.haier.rrskx.domain.AzEorderTitle;
import com.mj.haier.rrskx.repository.AzOrderTitleFinRepository;
import com.mj.haier.rrskx.service.AzEorderService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * AzEorderSyncResource controller
 */
@RestController
@RequestMapping("/api")
public class AzEorderResource {

    private final Logger log = LoggerFactory.getLogger(AzEorderResource.class);

    private final AzEorderService azEorderService;

    private final AzOrderTitleFinRepository azOrderTitleFinRepository;

    public AzEorderResource(AzEorderService azEorderService, AzOrderTitleFinRepository azOrderTitleFinRepository){
        this.azEorderService = azEorderService;
        this.azOrderTitleFinRepository = azOrderTitleFinRepository;
    }

    /**
    * GET List<AzEorderTitle>
    */
    @GetMapping("/az-eorders/{switcherValue}/{limit}")
    public List<AzEorderTitle> getAllAzEorders(@PathVariable String switcherValue, @PathVariable Integer limit) {

        log.debug("REST request to get list of AzEorderTitles");
        return azEorderService.fetchSyncAzEorderTitle(switcherValue, limit);
    }

    /**
     * GET updateAzOrderTitleFinSettle = 2
     * 
     * @param tradeCode
     * @param orderCode
     * @return
     */
    @GetMapping("/update/az-order-title-fin/{tradeCode}/{orderCode}")
    public int updateAzOrderTitleFinSettle(@PathVariable String tradeCode, @PathVariable String orderCode){
        
        log.debug("REST request to update AzOrderTitleFin settle = 2");
        return azOrderTitleFinRepository.updateAzOrderTitleFinSettle(tradeCode, orderCode);
    }

}
